package com.demon.activitychange;

import android.app.Application;

import com.demon.activitychange.persist.IPersist;
import com.demon.activitychange.persist.PersistKey;
import com.demon.activitychange.persist.impl.PersistFactory;
import com.demon.activitychange.util.TraceUtil;
import com.umeng.cconfig.RemoteConfigSettings;
import com.umeng.cconfig.UMRemoteConfig;
import com.umeng.cconfig.listener.OnConfigStatusChangedListener;
import com.umeng.commonsdk.UMConfigure;
import com.xy.vpnsdk.xyOpenSdk;

import org.xutils.x;

public class BaseApp extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        // 打开APP日志
        TraceUtil.setDebug(true);
        TraceUtil.setWriter(true);
        // xUtils初始化
        x.Ext.init(this);
        IPersist mPersist = PersistFactory.getInstance(this);
        String account = (String) mPersist.readData(PersistKey.LEIDIAN_ACCOUNT, "");
        String password = (String) mPersist.readData(PersistKey.LEIDIAN_PASSWORD, "");
        xyOpenSdk.getInstance().init(this, account, password);

        UMConfigure.setLogEnabled(true);
        UMRemoteConfig.getInstance().setConfigSettings(new RemoteConfigSettings.Builder().setAutoUpdateModeEnabled(false).build());
        UMRemoteConfig.getInstance().setOnNewConfigfecthed(new OnConfigStatusChangedListener() {
            @Override
            public void onFetchComplete() {
                TraceUtil.e("配置下载完成，激活相应的配置信息");
                UMRemoteConfig.getInstance().activeFetchConfig();
            }

            @Override
            public void onActiveComplete() {

            }
        });
        UMConfigure.init(this, "5f8e9c3880455950e4b0aa76", "Umeng", UMConfigure.DEVICE_TYPE_PHONE, null);
    }
}
